import Util from '../..//utils/util.js';

let app = getApp();
Component({
  properties: {
    swiperType: {
      type: String,
      value: ""
    },
    imgUrls: {
      type: Object,
      value: []
    },
    swiperClass: {
      type: String,
      value: ''
    },
    showEdit: {
      type: Boolean,
      value: false
    },
    location: {
      type: String,
      value: ''
    },
    is_dot_num: {
      type: Number,
      value: 0
    }
  },
  data: {
    circular: true,
    autoplay: true,
    interval: 300000,
    duration: 500,
    currentSwiper: 0
  },
  attached: function () {
  },
  methods: {
    swiperChange: function (e) {
      this.setData({
        currentSwiper: e.detail.current
      });
    },

    imgYu: function (event) {
      let imgList = this.data.imgUrls;
      const key = event.currentTarget.dataset.key
      let src = "";
      if (!Util.isEmpty(this.data.imgUrls[key]))
        src = Util.previewCdnImage(this.data.imgUrls[key].path)

      const urls = [];
      for (let i = 0; i < imgList.length; i++) {
        urls.push(Util.previewCdnImage(imgList[i]['path']));
      }

      if (urls) {
        wx.previewImage({
          current: src,
          urls: urls
        });
      }
    }
  }
});
